package com.zfei.gfb.dao;

import com.zfei.gfb.api.domain.EventTuple;
import com.zfei.gfb.model.TalkEventEntity;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;

import java.util.Collection;
import java.util.List;

/**
 * @author fgh
 */
@Mapper
public interface TalkEventMapper {

    int insertSelective(@Param("pojo") TalkEventEntity pojo);

    int update(@Param("pojo") TalkEventEntity pojo);

    TalkEventEntity findByEventId(@Param("eventId") String eventId);

    List<TalkEventEntity> findByEventIdList(@Param("eventIds") Collection<String> eventIds);

    List<EventTuple> findByAccount(@Param("account") String account,
                                   @Param("eventTiers") Collection<Integer> eventTiers,
                                   @Param("eventTypes") Collection<Integer> eventTypes,
                                   @Param("privileges") Collection<Integer> privileges,
                                   @Param("minTime") Long minTime, @Param("maxTime") Long maxTime,
                                   @Param("offset") Integer offset, @Param("limit") Integer limit,
                                   @Param("orderType") Integer orderType,
                                   @Param("validFlag") Integer validFlag);

    List<EventTuple> findByAccounts(@Param("accounts") Collection<String> accounts,
                                    @Param("eventTiers") Collection<Integer> eventTiers,
                                    @Param("eventTypes") Collection<Integer> eventTypes,
                                    @Param("privileges") Collection<Integer> privileges,
                                    @Param("minTime") Long minTime, @Param("maxTime") Long maxTime,
                                    @Param("offset") Integer offset, @Param("limit") Integer limit,
                                    @Param("orderType") Integer orderType,
                                    @Param("validFlag") Integer validFlag);

    int countByAccount(@Param("account") String account,
                       @Param("eventTiers") Collection<Integer> eventTiers,
                       @Param("eventTypes") Collection<Integer> eventTypes,
                       @Param("privileges") Collection<Integer> privileges,
                       @Param("minTime") Long minTime, @Param("maxTime") Long maxTime,
                       @Param("validFlag") Integer validFlag);

    List<EventTuple> findByAccountAndParent(@Param("account") String account,
                                            @Param("eventTiers") Collection<Integer> eventTiers,
                                            @Param("eventTypes") Collection<Integer> eventTypes,
                                            @Param("privileges") Collection<Integer> privileges,
                                            @Param("parents") Collection<String> parents);


    List<EventTuple> findByParent(@Param("parent") String parent, @Param("eventTiers") Collection<Integer> eventTiers,
                                  @Param("minTime") Long minTime, @Param("maxTime") Long maxTime,
                                  @Param("offset") Integer offset, @Param("limit") Integer limit,
                                  @Param("orderType") Integer orderType);


    int countByAccountAndContent(@Param("parent") String parent, @Param("eventTiers") Collection<Integer> eventTiers,
                                             @Param("minTime") Long minTime, @Param("maxTime") Long maxTime,
                                             @Param("content") String content, @Param("privileges") Collection<Integer> privileges,
                                             @Param("spam") String spam);

    List<EventTuple> findByAccountAndContent(@Param("parent") String parent, @Param("eventTiers") Collection<Integer> eventTiers,
                                             @Param("minTime") Long minTime, @Param("maxTime") Long maxTime,
                                             @Param("offset") Integer offset, @Param("limit") Integer limit,
                                             @Param("content") String content, @Param("privileges") Collection<Integer> privileges,
                                             @Param("spam") String spam, @Param("orderType") Integer orderType);

    void updatePrivilege(@Param("eventId")  String eventId, Integer privilege);

    void updateReply(List<String> eventIds);
}
